#ifndef __LIB_GUI_SIGNAL_H
#define __LIB_GUI_SIGNAL_H

#include"gui_event.h"

#define GUI_SIGNAL_NAME_LEN 32

typedef bool (*gui_callback_t)(gui_spirit_t *spirit,void *);
typedef bool (*gui_callback_event_t)(gui_spirit_t *spirit,gui_event_t *event,void *);

typedef struct 
{
    list_t list;
    void *callback;
    void *calldata;
    char name[GUI_SIGNAL_NAME_LEN+1];
    void *spirit;
}gui_signal_t;

#define GUI_CALLBACK(func) ((void*)(func))

int gui_signal_create(gui_spirit_t *spirit,const char *name);
int gui_signal_destroy(gui_spirit_t *spirit,const char *name);
int gui_signal_destroy_all(gui_spirit_t *spirit);
int gui_signal_connect(gui_spirit_t *spirit,const char *name,void *func,void *data);
bool gui_signal_emit_by_name(gui_spirit_t *spirit,const char *name);
bool gui_signal_emit_arg(gui_spirit_t *spirit,const char *name,void *arg);
int gui_spirit_emit(gui_spirit_t *spirit,int signal_id);


#endif 